//from the page we load this into:
//var numPhotos = $iNumPhotos;
//var photoArray = new Array( $photolist );
var currentImgNum=0;
var preloader=new Array();

function preloadListingImages() {
	if (photoArray.length > 1) for (var i=0; i<photoArray.length; i++) {
		preloader[i]=new Image();
		preloader[i].src=photoArray[i];
	}
}
//depends on addAnEvent function from main.js
//addAnEvent(window, 'load', preloadListingImages);

function swapNext() {
	if (photoArray.length > 1) swapListingImage(1);
}
function swapPrev() {
	if (photoArray.length > 1) swapListingImage(-1);
}
function swapListingImage(dir) {
	
	currentImgNum+=dir;
	currentImgNum%=numPhotos;
	if (currentImgNum<0) {
		currentImgNum=numPhotos-1;
	} else if (currentImgNum==numPhotos) {
		currentImgNum=0;
	}

	if (document.getElementById) {
		document.getElementById('homeImg').src=photoArray[currentImgNum][0];
		//document.getElementById('imgLink').href="";
	} else {
		document.home.src=photoArray[currentImgNum];
	}
}

function largeImage(dir)
{
	currentImgNum+=dir;
	currentImgNum%=numPhotos;
	if (currentImgNum<0) {
		currentImgNum=numPhotos-1;
	} else if (currentImgNum==numPhotos) {
		currentImgNum=0;
	}
	
	/*
	for (var i=0; i<photoArray.length; i++)
	{
		alert(photoArray[i]);
	}
	*/
		
//alert(photoArray[currentImgNum][1])	;

window.open('./showImage.php?in='+photoArray[currentImgNum][1],'mywin','left=20,top=20,width='+photoArray[currentImgNum][2]+',height='+photoArray[currentImgNum][3]+',toolbar=0,resizable=1,scrollbars=1');
}